package cn.itcast.spring;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class HttpClientTest {

	public static void main(String[] args) throws ClientProtocolException, IOException {
		ApplicationContext context = new AnnotationConfigApplicationContext(HttpClientConfiguration.class);
		HttpClient httpClient = context.getBean(HttpClient.class);
		String content = httpClient.execute(new HttpGet("https://www.baidu.com"), new BasicResponseHandler());
		System.out.println(content);
	}

}
